package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Order;
import cn.wolfcode.trip.base.domain.Score;
import cn.wolfcode.trip.base.query.OrderQueryObject;
import cn.wolfcode.trip.base.service.IOrderService;
import cn.wolfcode.trip.base.service.IScoreService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/scores")
public class ScoreController {

    @Autowired
    private IScoreService scoreService;

    /**
     * 根据用户id获取积分
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Score get(@PathVariable Long id) {
        return scoreService.selectScoreById(id);
    }

    /**
     * 支付更改积分
     * @param score
     * @return
     */
    @PostMapping
    public JsonResult updata(Score score){
        JsonResult result = new JsonResult();
        try {
            scoreService.updata(score);
        } catch (Exception e) {
            e.printStackTrace();
            result.mark("操作异常");
        }
        return result;
    }
}
